﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using RTGS.Library.Entities.Rtgs;
using RTGS.Library.DataAccess.Rtgs;
using System.Configuration;

namespace RTGS.Web.form.rtgs
{


public partial class form_rtgs_rule_form : BasePage
    {
        private string id = string.Empty;

        private    stpRuleRepo trnDal = new stpRuleRepo(ConfigurationManager.ConnectionStrings["Rtgs"].ConnectionString);

        private stpPriorityRepo stpPriorityrepo = new stpPriorityRepo(ConfigurationManager.ConnectionStrings["Rtgs"].ConnectionString);


        protected void Page_Load(object sender, EventArgs e)
        {

            List<stpPriority> liststpPriority = stpPriorityrepo.GetList();
            foreach (var item in liststpPriority)
            {
                ddlPriority.Items.Add(new ListItem(item.prioritycode, item.prioritycode));
            }

            ddlPriority.Items.Insert(0, new ListItem("---Pilih Data---", string.Empty));

            if (Request.Params["id"] != null)
            {
                id = Convert.ToString(Request.Params["id"]);
            }

            if (!Page.IsPostBack)
            {
                if (id.Trim().Length > 0) // Edit an existing item
                {
                    stpRule obj = trnDal.GetById(id);
                    if (obj != null)
                    {
                        hfID.Value = id.ToString();
                        txtRuleCode.Text = obj.rulecode;
                        txtRuleDesc.Text = obj.ruledesc;
                        txtRuleTime.Text = obj.ruletime;
                        txtRuleCustom.Text = obj.rulecustomtime;
                        ddlPriority.Items.FindByValue(obj.ruleprioritycode).Selected = true;
                       
                        
                    }
                }
            }

        }

    }
}